package com.yt.supplier.service;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.BeanUtils;
import javax.annotation.Resource;
import com.yt.supplier.common.config.YmlConfig;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.yt.supplier.mapper.SupplierInfoMapper;
import com.yt.supplier.models.service.ISupplierInfoService;
import com.yt.supplier.models.bo.SupplierInfoSaveBO;
import com.yt.supplier.models.dto.SupplierInfoDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 供应商信息控制器
 *
 * @author lizicong
 * @Date 2025-09-09 11:10:45
 */
@DubboService
@Service
public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, SupplierInfoDTO> implements ISupplierInfoService{

    @Resource
    private YmlConfig ymlConfig;
    @Autowired
    private SupplierInfoMapper supplierInfoMapper;
    @Override
    public boolean add(SupplierInfoSaveBO saveBO) {
        SupplierInfoDTO dto = new SupplierInfoDTO();
        BeanUtils.copyProperties(saveBO,dto);
        Long id = ymlConfig.getPkId();
        dto.setId(id);
        return this.insert(dto);
    }

    @Override
    public List<SupplierInfoDTO> SearchSupplierlist(String keyword) {
        Wrapper wrapper = new EntityWrapper<>();
        wrapper.like("supplier_name",keyword)
                .or()
                .like("phone",keyword);
        List<SupplierInfoDTO> list = supplierInfoMapper.selectList(wrapper);
        return list;
        }
}
